<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%>
<%@page import="java.util.*" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	Map threads=new TreeMap(); request.setAttribute("threads",threads);
	for(Map.Entry<Thread, StackTraceElement[]> me: Thread.getAllStackTraces().entrySet()) {
		//if(!"RUNNABLE".equals(me.getKey().getState())) continue;
		String s=me.getKey().getName(), s1="";
		for(StackTraceElement ste: me.getValue()){
		    if("".equals(s1) && (ste.getClassName().startsWith("cn.pc")||ste.getClassName().startsWith("cn.com.pc"))) s1="-->"+ste.toString();
		    if(ste.getClassName().startsWith("_jsp")) { s+=" --- <b>"+ste+"</b>"; break; }
		}
		threads.put(s+s1,me);
	}
%>
<title><%=threads.size()%> threads@<%=java.net.InetAddress.getLocalHost()%>:<%=request.getServerPort()%></title>
<style>body{font-size:9pt; white-space:nowrap; }</style>
/RUNNABLE/
<c:forEach var='t' items='${threads}'>
<c:if test="${t.value.key.state=='RUNNABLE'}">
<div id=b${t.value.key.id}
	onmouseover="style.textDecoration='underline'"
	onmouseout="style.textDecoration=''"
	onclick="var d=nextSibling.style;d.display=d.display!='none'?'none':''">
	${t.key}
<%--
</div><div id=div${t.value.key.id} style=display:none>
<c:forEach var="s" items="${t.value.value}">
&nbsp;&nbsp;&nbsp;&nbsp;${s}<br></c:forEach>
--%>
</div>
</c:if></c:forEach>

<hr>
/not RUNNABLE/
<div style="color:gray">
<c:forEach var='t' items='${threads}'>
<c:if test="${t.value.key.state!='RUNNABLE'}">
<div id=b${t.value.key.id}
	onmouseover="style.textDecoration='underline'"
	onmouseout="style.textDecoration=''"
	onclick="var d=nextSibling.style;d.display=d.display!='none'?'none':''">
	${t.key}
<%--
</div><div id=div${t.value.key.id} style=display:none>
<c:forEach var="s" items="${t.value.value}">
&nbsp;&nbsp;&nbsp;&nbsp;${s}<br></c:forEach>
--%>
</div>
</c:if></c:forEach>
</div>
<% out.flush(); %>
<c:forEach var='t' items='${threads}'>
<div id=div${t.value.key.id} style=display:none>
<c:forEach var="s" items="${t.value.value}">
&nbsp;&nbsp;&nbsp;&nbsp;${s}<br></c:forEach>
</div>
<script>var e=document.getElementById('b${t.value.key.id}');e.parentNode.insertBefore(document.getElementById('div${t.value.key.id}'),e.nextSibling)</script>
</c:forEach>
